home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / OutOfContextMenus / Source / WaitNextEventPatch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-06-24  |  2.2 KB  |  95 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    WaitNextEventPatch.c                 ©1999 Eric Traut
  3. // ===========================================================================
  4.  
  5. // This file implements a WaitNextEvent patch that can be applied within
  6. // the Finder that keeps it from specifying a sleep time that is too long.
  7.  
  8. #include "WaitNextEventPatch.h"
  9.  
  10. #include <Events.h>
  11. #include <Patches.h>
  12. #include <Traps.h>
  13. #include <Gestalt.h>
  14.  
  15. static void                DataForPatch(void);
  16. static pascal Boolean    WaitNextEventPatch(EventMask eventMask, EventRecord * theEvent, UInt32 sleep, RgnHandle mouseRgn);
  17.  
  18.  
  19. // ---------------------------------------------------------------------------
  20. //        • main (InstallPatch)
  21. // ---------------------------------------------------------------------------
  22.  
  23. pascal void
  24. main(void)
  25. {
  26.     WNEPatchInfo *        patchInfo;
  27.     patchInfo = (WNEPatchInfo *)&DataForPatch;
  28.     
  29.     patchInfo->fPatchEntry = &WaitNextEventPatch;
  30.     patchInfo->fPatchCallThrough = (WaitNextEventProc)GetToolTrapAddress(_WaitNextEvent);
  31.     patchInfo->fPatchActive = true;
  32.     
  33.     SetToolTrapAddress((UniversalProcPtr)&WaitNextEventPatch, _WaitNextEvent);
  34. }
  35.  
  36.  
  37. // ---------------------------------------------------------------------------
  38. //        • WaitNextEventPatch
  39. // ---------------------------------------------------------------------------
  40.  
  41. pascal Boolean
  42. WaitNextEventPatch(
  43.     EventMask                 eventMask,
  44.     EventRecord *            theEvent,
  45.     UInt32                     sleep,
  46.     RgnHandle                 mouseRgn)
  47. {
  48.     WNEPatchInfo *        patchInfo;
  49.     patchInfo = (WNEPatchInfo *)&DataForPatch;
  50.     
  51.     (void) DeleteGestaltValue(gestaltWNEPatch);
  52.     (void) NewGestaltValue(gestaltWNEPatch, (long)patchInfo);
  53.     
  54.     if (patchInfo->fPatchActive)
  55.         sleep = 1;
  56.     
  57.     return (*patchInfo->fPatchCallThrough)(eventMask, theEvent, sleep, mouseRgn);
  58. }
  59.  
  60.  
  61. // ---------------------------------------------------------------------------
  62. //        • DataForPatch
  63. // ---------------------------------------------------------------------------
  64.  
  65. void
  66. DataForPatch(void)
  67. {
  68.     Debugger();
  69.     Debugger();
  70.     Debugger();
  71.     Debugger();
  72.     Debugger();
  73.     Debugger();
  74.     Debugger();
  75.     Debugger();
  76.     Debugger();
  77.     Debugger();
  78.     Debugger();
  79.     Debugger();
  80.     Debugger();
  81.     Debugger();
  82.     Debugger();
  83.     Debugger();
  84.     Debugger();
  85.     Debugger();
  86.     Debugger();
  87.     Debugger();
  88.     Debugger();
  89.     Debugger();
  90. }
  91.  
  92.  
  93.  
  94.  
  95.